public class Person
{
    String name;
    int age;
    char gender;
    boolean married;
    boolean judge=true;
    public void marry( Person another )
    {
        // 在这⾥填空，判断⾃⼰ ( this ) 跟 另外⼀个⼈( another )结婚
        if(this.gender==another.gender)
        {
            System.out.println("性别相同不能结婚");
              judge=false;
        }

             if((this.married==true && another.married==true)||(this.married==true && another.married==false)||(this.married==false && another.married==true))
            {
                System.out.println("已婚不能再婚");
                judge=false;
            }
                 if((this.gender=='男'&&this.age<22)||(another.gender=='女' && another.age<20)||(this.gender=='女' && this.age<20)||(another.gender=='男' && another.age<22))
                 {
                     System.out.println("年龄不符合");
                     judge = false;


                 }
                        if(judge==true)
                        {
                            System.out.println("可以结婚");
                        }

    }

    public static void main(String[] args)
    {
        Person first = new Person();
        first.name="杨过";
        first.age=23;
        first.gender='男';
        first.married=false;
        Person second=new Person();
        second.name="小龙女";
        second.age=21;
        second.married=false;
        second.gender='女';
        first.marry(second);

    }
}
